Class sjl.ReverseBidirectionalIterator
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sjl.ReverseBidirectionalIterator

java.lang.Object
   |
   +----sjl.Iter
           |
           +----sjl.ReverseBidirectionalIterator

public class ReverseBidirectionalIterator
extends Iter
implements BidirectionalIterator
ReverseBidirectionalIterator is an iterator adapter that will traverse the container in the reverse order of an ordinary BidirectionalIterator.
    BidirectionalIterator iter = new ReverseBidirectionalIterator(coll.end());
    for (; i.cmp(coll.begin()); i.next()) { ... }
The same functionallity can be found with.
    for (BidirectionalIterator iter = coll.rend(); i.cmp(coll.rbegin()); i.next()) { ... }
Any BidirectionalIterator "iter" can be turned into a reverse iterator with:
    Bidirectional reverse_iter = Iter.reverse(iter);
XXX: Not true.

Copyright © 1996 Finn Bock


Constructor Index

 o ReverseBidirectionalIterator(BidirectionalIterator)
Contruct a ReverseBidirectionalIterator for the iterator.

Method Index

 o cmp(Iterator)
Compares two iterators.
 o distance(Iterator)
Returns the distance between two iterators.
 o genericCopy()
Create a copy of the this.
 o get()
Return the current value pointed to by the iterator.
 o next()
Advance the iterator to the next element.
 o prev()
Advance the iterator to the previous element.
 o put(Object)
Places a new element in the position pointed to by the iterator.
 o setTo(Iterator)
Assign this iterator to another iterator.

Constructors

 o ReverseBidirectionalIterator
  public ReverseBidirectionalIterator(BidirectionalIterator iter)
Contruct a ReverseBidirectionalIterator for the iterator. The newly contructed iterator will have a reference to the argument iterator. Each time next() and prev() is called on the ReverseBidirectionalIterator, the argument iterator is move back and forward.
Parameters:
iter - A BidirectionalIterator.

Methods

 o genericCopy
  public Iterator genericCopy()
Create a copy of the this. The copy can then be moved without affecting this.
Returns:
A new iterator pointing to the same element as this.
 o setTo
  public void setTo(Iterator i)
Assign this iterator to another iterator. This is faster than creating a new ReverseBidirectionalIterator object.
 o next
  public Iterator next()
Advance the iterator to the next element. Calls prev() on the actual iterator.
 o prev
  public Iterator prev()
Advance the iterator to the previous element. Calls next() on the actual iterator.
 o get
  public Object get()
Return the current value pointed to by the iterator.
 o put
  public Object put(Object o)
Places a new element in the position pointed to by the iterator.
 o cmp
  public boolean cmp(Iterator i)
Compares two iterators.
Returns:
true if the iterators point to the same position.
 o distance
  public int distance(Iterator i)
Returns the distance between two iterators.

All Packages  Class Hierarchy  This Package  Previous  Next  Index